package com.web;

import com.domain.Department;
import com.service.departmentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
 * 修改员工个人数据，现在查询部门信息
 * 提交到departmentService 的 findAllDepartment函数
 * 转发到 updateEmployee.jsp 页面进行展示
 */
@WebServlet("/findMyself")
public class findMyselfServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.解决乱码
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        //2.进行查询部门
        List<Department> allDepartment = new departmentService().findAllDepartment();
        //3.进行存储
        request.setAttribute("departmentList",allDepartment);
        //4.转发
        request.getRequestDispatcher("/updateEmployee.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
